﻿using SameGame.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SameGame.Presentation.Presenters
{
	class BoardScorePresenter : IBoardScorePresenter
	{
		IBoard _board;
		IBoardScoreView _view;

		public BoardScorePresenter(IBoard board)
		{
			_board = board;
		}

		void _board_ScoreChanged(object sender, EventArgs e)
		{
			_view.Score = _board.Score;
		}

		public IBoardScoreView View
		{
			get
			{
				return _view;
			}
			set
			{
				_view = value;
				if (_view == null)
					_board.ScoreChanged -= _board_ScoreChanged;
				else
					_board.ScoreChanged += _board_ScoreChanged;
			}
		}
	}
}
